package org.millioncall.yueyoga.admin.service.impl;

import java.util.List;
import java.util.Map;

import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.yueyoga.admin.dao.StatusDAO;
import org.millioncall.yueyoga.admin.model.Status;
import org.millioncall.yueyoga.admin.service.StatusService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class StatusServiceImpl implements StatusService {
	private static final Logger logger = LoggerFactory.getLogger(Status.class);
	private StatusDAO statusDAO;

	public StatusDAO getStatusDAO() {
		return statusDAO;
	}

	public void setStatusDAO(StatusDAO statusDAO) {
		this.statusDAO = statusDAO;
	}

	@Override
	public List<Status> findByType(int i) {
		return this.statusDAO.findByType(i);
	}

	@Override
	public List<Status> findByParentCode(String code) {
		return this.statusDAO.findByParentCode(code);
	}

	@Override
	public Status findByCode(String code) {
		return this.statusDAO.findByCode(code);
	}

	@Override
	public Status findById(int id) {
		return this.statusDAO.findById(id);
	}

	@Override
	public PaginatedList<Status> getStatusInPage(int i, int pageSize,
			Map<String, Object> map) {
		return this.statusDAO.getStatusInPage(i, pageSize, map);
	}

	@Override
	public boolean insert(Status status) {
		int i = statusDAO.insert(status);
		if (i > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void deleteStatusByIds(Integer[] deids) {
		if (deids == null || deids.length == 0) {
			logger.error("未提交要删除会员的编号");
			throw new RuntimeException(" 未提交要删除会员的编号");
		} else {
			this.statusDAO.deleteByIds(deids);
		}
	}

	@Override
	public boolean update(Status status) {
		int i = statusDAO.update(status);
		if (i > 0) {
			return true;
		} else {
			return false;
		}
	}

}